<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="width=device-width,initial-scale=1,user-scalable=0">
<title>地址信息</title>
<%@ include file="/pages/wx/baseHead.jsp"%>
<!-- 引入地图 -->
<script type="text/javascript">
	function showDia(id) {
		$('#' + id).show();
	}
	function hideDia(id) {
		$('#' + id).hide();
	}

	
	/*  获得焦点  */
	$("#addressDetail").bind("click", function() {
		$("#addressDetail")[0].focus();
	});

	function callId() {
		var random = Math.floor(Math.random() * 10001);
		var id = (random + "_" + new Date().getTime()).toString();
		return id;
	}

	function createToken(formId) {
		$('#' + formId)
				.append(
						"<input type='hidden' id='YS-EXPRESS-KEY' name='YS-EXPRESS-KEY'/>");
		$('#' + formId).find($('input[name="YS-EXPRESS-KEY"]')).val(callId());
	}
	
	function getLocation()
	{
		getLocationH5(function(data){
			var proText  = data.province;
			var cityText = data.city;
			setProAndCity(proText,cityText);
			$("#addressDetail").val(data.list[0]);
		});
	}
	
	function del(id)
	{
		confirm("提示信息","确认删除该记录？",function(){
			var url = 'deteAddr.do?SN='+id;
			window.location.href = url;
		})
		
	}
	
</script>
</head>
<body ontouchstart>
	<div class="bd">
		<!-- <div class="page_title" style="padding-top: 10px;font-size: 2em;">收件人详细信息</div>
 				<p class="page_desc">请认真填写下面信息</p> -->
		<div class="cell">
				<div class="weui_cells weui_cells_form" style="margin-top: 10px;">
					<c:if test="${flag==0 }">
						<form action="${urlBasePath}weixin/user/updateAddr.do" method="post"
							onsubmit="">
							<input type="hidden" id="sn" name="sn" value="${addr.sn }" />
					</c:if>
					<c:if test="${flag!=0 }">
						<form action="${urlBasePath}weixin/user/preAddr.do"  method="post">
							<script type="text/javascript">
								createToken('addForm');
							</script>
					</c:if>
					<input type="hidden" name="rs" value="${rs }">
					<div class="weui_cell">
						<div class="weui_cell_hd">
							<label class="weui_label" style="font-weight: normal;">名称</label>
						</div>
						<div class="weui_cell_bd weui_cell_primary">
							<input class="weui_input" type="text" placeholder="联系人名称，最大长度20"
								maxlength="20" id="receiveName" name="receiveName" pattern="^\S*$"
								value="${addr.receiveName }" autocomplete="on"
								autofocus="autofocus" required="required" />
						</div>
					</div>
					<div class="weui_cell" style="display: none;">
						<div class="weui_cell_hd">
							<label class="weui_label" style="font-weight: normal;">邮编</label>
						</div>
						<div class="weui_cell_bd weui_cell_primary">
							<input class="weui_input" type="txt" pattern="^[1-9]\d{5}(?!\d)$"
								placeholder="默认000000,不填即可" maxlength="8" id="postcode"
								name="postcode" value="${addr.postcode }" />
						</div>
					</div>
					<div class="weui_cell">
						<div class="weui_cell_hd">
							<label class="weui_label" style="font-weight: normal;">手机</label>
						</div>
						<div class="weui_cell_bd weui_cell_primary">
							<input class="weui_input" type="tel" pattern="^[1][3-8]+\d{9}$"
								placeholder="收件人手机" id="receiveCellPhone"
								name="receiveCellPhone" value="${addr.receiveCellPhone }"
								maxlength="11" required="required" />
						</div>
					</div>
					<div class="weui_cell" style="display: none;">
						<div class="weui_cell_hd">
							<label class="weui_label" style="font-weight: normal;">电话</label>
						</div>
						<div class="weui_cell_bd weui_cell_primary">
							<input class="weui_input" type="tel" placeholder="收件人电话"
								id="receivePhone" name="receivePhone"
								value="${addr.receivePhone }" maxlength="12" />
						</div>
					</div>
					<div class="weui_cell">
						<div class="weui_cell_hd">
							省份
						</div>
						<div class="weui_cell_bd weui_cell_primary">
						<select class="weui_select" id="prov" name="proCode" onchange="syncCity();" required="required"></select>
						</div>
						<div style="float: right;">
							<a href="javascript:;" onclick="getLocation();" class="weui_btn weui_btn_plain_primary weui_btn_mini ">
	            					<i class="fa fa-map-marker fa-fw"></i>定位
	            			</a>
            			</div>
					</div>
					<div class="weui_cell">
						<div class="weui_cell_hd">
							城市
						</div>
						<div class="weui_cell_bd weui_cell_primary">
						<select  class="weui_select" id="city" name="cityCode" required="required"></select>
						</div>
					</div>
					<div class="weui_cell">
						<div class="weui_cell_hd">
							<label class="weui_label" style="font-weight: normal;">详情</label>
						</div>
						<div class="weui_cell_bd weui_cell_primary">
							<textarea class="weui_textarea" placeholder="请输入详细地址" rows="2" 
							id="addressDetail" name="addressDetail" pattern="^\S*$"
							maxlength="50"
							>${addr.addressDetail }</textarea>								
						</div>
						<!-- <div class="weui_cell_hd" style="padding-left: 1em;">
							<a href="javascript:;" onclick="getLocation();" class="weui_btn weui_btn_plain_primary weui_btn_mini ">
            					<i class="fa fa-map-marker fa-fw"></i>定位
            				</a>
            			</div> -->
					</div>
					
					<div class="weui_cell">
						<div class="weui_cell_hd">
							<label class="weui_label" style="font-weight: normal;">默认</label>
						</div>
						<div class="weui_cell_ft">
							<c:if test="${addr.isDefault=='00' }">
								<input class="weui_switch" type="checkbox" id="isDefault"
									name="isDefault" checked="checked" />
							</c:if>
							<c:if test="${addr.isDefault!='00' }">
								<input class="weui_switch" type="checkbox" id="isDefault"
									name="isDefault">
							</c:if>
						</div>
					</div>					
					
					<!-- 保存还是新增  -->
					<c:if test="${flag==0 }">
						<div class="bd spacing form-inline">
							<input class="weui_btn weui_btn_primary"  type="submit" value="保存" /> 
							<input type="button" onclick="del('${addr.sn}');" 
							class="weui_btn weui_btn_primary weui_btn_warn" value="删除" />
						</div>
					</c:if>
					<c:if test="${flag!=0 }">
						<div class="bd spacing">
							<input class="weui_btn weui_btn_primary" id="showSave"
								type="submit" value="保存" />
						</div>
					</c:if>
<!-- 
					<div class="button_sp_area" align="center">
				        <a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_primary"  
				        	style="width: 40%;height: 40px;padding-top: 5px;">保存</a>
				        <a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_warn"  
				        	style="width: 40%;height: 40px;padding-top: 5px;">删除</a>
				    </div>
					<div style="height: 200px;display: block;"></div> -->
					</form>


				</div>

				<div class="weui_dialog_confirm" id="dialog1" style="display: none;">
					<div class="weui_mask"></div>
					<div class="weui_dialog">
						<div class="weui_dialog_hd">
							<strong class="weui_dialog_title">确认删除？</strong>
						</div>
						<div class="weui_dialog_ft">
							<a href="javascript:;" onclick="hideDia('dialog1')"
								class="weui_btn_dialog default">取消</a> <a
								href="receManage.do?method=deteAddr&SN=${addr.sn }"
								class="weui_btn_dialog primary">确定</a>
						</div>
					</div>
				</div>
		</div>
	</div>

<div class="pop">
    <i class="fa fa-home fa-lg popi"></i>
</div>

<!-- 引入微信样式代码提示工具开始 -->
<%@ include file="/pages/wx/wxClass.jsp"%>
<!-- 引入微信样式代码提示工具结束 -->
<%@ include file="/pages/wx/baseBottom.jsp"%>

<script type="text/javascript">


var provjson = '${provjson}';
var cityjson = '${cityjson}';

$(function(){
	syncCity('${addr.proCode }','${addr.cityCode }');
})
</script>	



</body>
</html>

